import { Ticket } from '@/types/ticket';

// 简单的 UUID 生成函数
const generateId = (): string => {
  return Date.now().toString(36) + Math.random().toString(36).substr(2);
};

export const mockTickets: Ticket[] = [
  {
    id: '1',
    title: '网站首页加载速度慢',
    description: '用户反馈网站首页加载时间超过5秒，需要优化页面性能。检查图片压缩、代码分割等优化方案。',
    status: 'open',
    priority: 'high',
    category: 'bug',
    assignee: '张三',
    reporter: '李四',
    createdAt: '2024-01-10T08:30:00Z',
    updatedAt: '2024-01-10T08:30:00Z',
    dueDate: '2024-01-15T18:00:00Z',
    tags: ['性能优化', '首页', 'UI'],
  },
  {
    id: '2',
    title: '添加用户头像上传功能',
    description: '用户需要能够上传和更换个人头像，支持常见图片格式，自动裁剪和压缩。',
    status: 'in_progress',
    priority: 'medium',
    category: 'feature',
    assignee: '王五',
    reporter: '赵六',
    createdAt: '2024-01-08T14:20:00Z',
    updatedAt: '2024-01-11T10:15:00Z',
    dueDate: '2024-01-20T18:00:00Z',
    tags: ['用户体验', '头像', '上传'],
  },
  {
    id: '3',
    title: '修复登录页面输入框样式问题',
    description: '在移动端设备上，登录页面的输入框显示异常，文字被截断。需要修复响应式样式。',
    status: 'resolved',
    priority: 'medium',
    category: 'bug',
    assignee: '孙七',
    reporter: '周八',
    createdAt: '2024-01-05T16:45:00Z',
    updatedAt: '2024-01-09T11:30:00Z',
    tags: ['移动端', '样式', '登录'],
  },
  {
    id: '4',
    title: '数据库性能优化',
    description: '随着用户量增长，数据库查询变慢。需要分析慢查询，添加索引，优化 SQL 语句。',
    status: 'open',
    priority: 'urgent',
    category: 'maintenance',
    assignee: '吴九',
    reporter: '郑十',
    createdAt: '2024-01-12T09:00:00Z',
    updatedAt: '2024-01-12T09:00:00Z',
    dueDate: '2024-01-14T18:00:00Z',
    tags: ['数据库', '性能', '优化'],
  },
  {
    id: '5',
    title: '集成第三方支付系统',
    description: '为电商模块集成支付宝和微信支付，包括支付回调处理和订单状态同步。',
    status: 'open',
    priority: 'high',
    category: 'feature',
    assignee: '钱十一',
    reporter: '孙十二',
    createdAt: '2024-01-11T13:20:00Z',
    updatedAt: '2024-01-11T13:20:00Z',
    dueDate: '2024-01-25T18:00:00Z',
    tags: ['支付', '集成', '电商'],
  },
  {
    id: '6',
    title: '用户反馈邮箱验证失败',
    description: '部分用户注册时收不到邮箱验证邮件，需要检查邮件服务配置和发送逻辑。',
    status: 'in_progress',
    priority: 'medium',
    category: 'support',
    assignee: '李十三',
    reporter: '王十四',
    createdAt: '2024-01-09T11:15:00Z',
    updatedAt: '2024-01-10T15:45:00Z',
    tags: ['邮箱', '验证', '注册'],
  },
  {
    id: '7',
    title: '添加数据导出功能',
    description: '管理员需要能够导出用户数据和订单数据为 Excel 格式，方便数据分析。',
    status: 'closed',
    priority: 'low',
    category: 'feature',
    assignee: '张十五',
    reporter: '赵十六',
    createdAt: '2024-01-03T10:30:00Z',
    updatedAt: '2024-01-07T16:20:00Z',
    tags: ['导出', '数据', 'Excel'],
  },
  {
    id: '8',
    title: '修复购物车商品数量更新问题',
    description: '用户在购物车中修改商品数量时，页面没有实时更新总价，需要刷新页面才能看到正确价格。',
    status: 'open',
    priority: 'high',
    category: 'bug',
    assignee: '孙十七',
    reporter: '周十八',
    createdAt: '2024-01-12T14:10:00Z',
    updatedAt: '2024-01-12T14:10:00Z',
    dueDate: '2024-01-16T18:00:00Z',
    tags: ['购物车', '实时更新', '价格计算'],
  },
];

export const generateMockTicket = (overrides: Partial<Ticket> = {}): Ticket => {
  const now = new Date().toISOString();
  return {
    id: generateId(),
    title: '新建工单',
    description: '工单描述',
    status: 'open',
    priority: 'medium',
    category: 'bug',
    reporter: '系统用户',
    createdAt: now,
    updatedAt: now,
    ...overrides,
  };
}; 